package com.wr.elasticsearch.controller;

import com.wr.elasticsearch.entity.Content;
import com.wr.elasticsearch.service.SearchServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@RestController
public class SearchController {

    @Autowired
    private SearchServiceImpl searchService;

    @GetMapping("/search/{keywords}/{pageNum}/{pageSize}")
    public List<Content> search(@PathVariable("keywords") String keywords,
                                @PathVariable("pageNum")int pageNum,
                                @PathVariable("pageSize")int pageSize) throws IOException {
        return searchService.search(keywords, pageNum, pageSize);
    }
}
